﻿using Lucid.ESA.ClientDataSystem.Domain.Common;
using Lucid.ESA.ClientDataSystem.Domain.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Lucid.ESA.ClientDataSystem.UnitTests.Domain
{
    [TestClass]
    public class ClientTests
    {
        [TestMethod]
        public void CanCreateValidClient()
        {
            Client client = Client.Create("Mauve Corporation");
            ValidationMessageCollection messages = client.Validate();

            Assert.AreEqual(0, messages.Count);
            Assert.AreEqual("Mauve Corporation", client.Name);
        }

        [TestMethod]
        public void CanEditValidClient()
        {
            Client client = Client.Create("Mauve Corporation");
            client.Edit("Ochre Enterprises");
            ValidationMessageCollection messages = client.Validate();

            Assert.AreEqual(0, messages.Count);
            Assert.AreEqual("Ochre Enterprises", client.Name);
        }

        [TestMethod]
        public void InvalidClientReturnsErrors()
        {
            Client client = Client.Create(null);
            ValidationMessageCollection messages = client.Validate();

            Assert.AreEqual(1, messages.Count);
            Assert.IsTrue(messages.ContainsError("Name", "Name cannot be empty."));
        }
    }
}
